package com.example.experiment_three;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    TextView text;
    Button btn_one_activity_listener,
            btn_two_innerClass_listener,
            btn_three_anonymous_innerClass_listener,
            btn_four_lambda_listener,
            btn_five_outerClass_listener,
            btn_six_label_listener,
            btn_seven_showConfiguration,
            btn_eight_showProgressDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        text = (TextView)findViewById(R.id.text_two);

        btn_one_activity_listener = (Button)findViewById(R.id.button1);
        btn_one_activity_listener.setOnClickListener(this);

        btn_two_innerClass_listener = (Button)findViewById(R.id.button2);
        btn_two_innerClass_listener.setOnClickListener(new InnerClassListener());

        btn_three_anonymous_innerClass_listener = (Button)findViewById(R.id.button3);
        btn_three_anonymous_innerClass_listener.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                text.setText("按钮3被点击");
            }
        });

        btn_four_lambda_listener = (Button)findViewById(R.id.button4);
        btn_four_lambda_listener.setOnClickListener(new InnerClassListener());
        btn_four_lambda_listener.setOnClickListener(view -> text.setText("按钮4被点击"));

        btn_five_outerClass_listener = (Button)findViewById(R.id.button5);
        btn_five_outerClass_listener.setOnClickListener(new OuterClassListener(text));

        btn_six_label_listener = (Button)findViewById(R.id.button6);

        btn_seven_showConfiguration = (Button) findViewById(R.id.button7);
        btn_seven_showConfiguration.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                text.setText("按钮7被点击");
                Intent i = new Intent(MainActivity.this, ConfigurationTest.class);
                startActivity(i);

            }
        });

        btn_eight_showProgressDialog = (Button) findViewById(R.id.button8);
        btn_eight_showProgressDialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                text.setText("按钮8被点击");
                Intent i = new Intent(MainActivity.this,ProgressDialogTest.class);
                startActivity(i);
            }
        });


        
    }


    @Override
    public void onClick(View view) {
        text.setText("按钮1被点击");

    }

    class InnerClassListener implements View.OnClickListener{
        @Override
        public void onClick(View view) {
            text.setText("按钮2被点击");
        }
    }


    public void myClick(View view) {
        text.setText("按钮6被点击");

    }
}


